#include "imUtils.h"

Clock::Clock(void) {
	TimeScale = 1.0f;
	MaxJump = 0.1f;
	c = 0.0f;

	QueryPerformanceFrequency(&Frequency);
		
	QueryPerformanceCounter(&T2);

	InvFrequency = 1.0f / Frequency.QuadPart;
}

void Clock::Update(void) {
	QueryPerformanceCounter(&T1);

	float TimeDelta = (T1.QuadPart - T2.QuadPart) * InvFrequency;

	LastJump = min(TimeDelta * TimeScale, MaxJump);
	c += LastJump;

	T2 = T1;
}

void Clock::SetTimeScale(float NewTS) {
	TimeScale = NewTS;
}

float Clock::GetTimeScale(void) {
	return TimeScale;
}

float Clock::GetTime(void) {
	return c;
}

float Clock::GetLastJump(void) {
	return LastJump;
}